#include "llbzc.h"
#include "ui_llbzc.h"
#include <mainwindow.h>
extern QSqlDatabase db;
llbzc::llbzc(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::llbzc)
{

      ui->setupUi(this);
        //设置图片
        // QPixmap *pix = new QPixmap(":/sunny.png");
        // QSize sz = ui->label_6->size();
        // ui->label_6->setPixmap(pix->scaled(sz));

}

llbzc::~llbzc()
{
    delete ui;
}

void llbzc::on_pushButton_clicked()
{
    MainWindow *w = new MainWindow;
    w->show();
    this->close();
}


void llbzc::on_pushButton_2_clicked()
{

        //sqlite_Init();
        QString username = ui->lineEdit->text();
        QString password = ui->lineEdit_2->text();
        QString surepass = ui->lineEdit_3->text();
        //判断密码是否一致
        if(password == surepass)
        {
            QString sql=QString("insert into user(username,password) values('%1','%2');")
            .arg(username).arg(password);
            //创建执行语句对象
            QSqlQuery query(db);
            //判断执行结果
            if(!query.exec(sql))
            {
                qDebug()<<"insert into error";
                QMessageBox::information(this,"注册认证","插入失败！");
            }
            else
            {
                qDebug()<<"insert into success";
                QMessageBox::information(this,"注册认证","插入成功！");
                MainWindow *w = new MainWindow;
                w->show();
                this->close();
            }

        }else{
            QMessageBox::information(this,"注册认证","两次密码输入不一致");
        }

}

